import * as _api from '@/api/system/resourceField'

const state = {}

const mutations = {}

const _promise = function(fun, params) {
  return new Promise((resolve, reject) => {
    fun(params)
      .then(data => {
        resolve(data)
      })
      .catch(error => {
        reject(error)
      })
  })
}

const actions = {
  // add
  add({ commit, state }, params) {
    return _promise(_api.add, params)
  },
  // edit
  edit({ commit, state }, params) {
    return _promise(_api.edit, params)
  },
  // remove
  remove({ commit, state }, params) {
    return _promise(_api.remove, params)
  },
  // page
  page({ commit, state }, params) {
    return _promise(_api.page, params)
  },
  // getType
  getType({ commit, state }, params) {
    return _promise(_api.getType, params)
  },
  // type
  type({ commit, state }, params) {
    return _promise(_api.type, params)
  },
  // dataScopePage
  dataScopePage({ commit, state }, params) {
    return _promise(_api.dataScopePage, params)
  },
  // dataScopeSave
  dataScopeSave({ commit, state }, params) {
    return _promise(_api.dataScopeSave, params)
  },
  // dataScopeUpdate
  dataScopeUpdate({ commit, state }, params) {
    return _promise(_api.dataScopeUpdate, params)
  },
  // dataScopeRemove
  dataScopeRemove({ commit, state }, params) {
    return _promise(_api.dataScopeRemove, params)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
